<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title></title>
</head>
<body>

<!--页面内容开始-->
<div class="wrapper wrapper-content">
    <div class="row animated fadeInRight">
        <div class="col-md-4">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>资料详情</h5>
                </div>
                <div>
                    <div class="ibox-content no-padding border-left-right">
                        <!--                        <img alt="image" class="img-fluid" src="img/profile_big.jpg">-->
                    </div>
                    <div class="ibox-content profile-content">
                        <form role="form" id="profile_form">
                            <input name="id" type="hidden">
                            <div class="form-group"><label>姓名</label> <input
                                    id="profile_name" name="name"
                                    type="text" class="form-control"></div>
                            <div class="form-group"><label>工号</label> <input
                                    id="profile_workNo" name="workNo"
                                    type="text" class="form-control" disabled></div>

                        </form>
                        <div>
                            <button class="btn btn-primary btn-block m-t-n-xs" type="button"
                                    onclick="appointimeruleSpecialObj.submitHandler()">
                                保存信息
                            </button>
                            <button class="btn btn-info btn-block m-t-n-xs" type="button"
                                    onclick="appointimeruleSpecialObj.submitHandler()">
                                修改登录密码
                            </button>
                            <button class="btn btn-success btn-block m-t-n-xs" type="button"
                                    onclick="appointimeruleSpecialObj.submitHandler()">
                                修改审核密码
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-8">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>签章管理</h5>
                </div>
                <div class="ibox-content">

                    <div>
                        <div class="feed-activity-list">

                            <div class="feed-element">
                                <a href="#" title="签章" data-gallery="profileGallery" class="float-left">
                                    <img id="profile_img_sign" alt="签章" src="" style="width: 100px">
                                </a>
                                <div class="media-body ">
                                    <a data-type="sign" onclick="profileObj.deleteHandler()" class="trash btn btn-white btn-bitbucket text-success pull-right" data-toggle="tooltip" title="删除">
                                        <i class="fa fa-trash"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="feed-element">
                                <a href="#" title="签章" data-gallery="profileGallery" class="float-left">
                                    <img id="profile_img_agree" alt="同意支付" src="" style="width: 100px">
                                </a>
                                <div class="media-body ">
                                    <a data-type="agree" onclick="profileObj.deleteHandler()" class="trash btn btn-white btn-bitbucket text-success pull-right" data-toggle="tooltip" title="删除">
                                        <i class="fa fa-trash"></i>
                                    </a>
                                </div>
                            </div>
                        </div>

                        <div class="pull-right">
                            <span class="btn btn-primary m-t-xs fileinput-button">
                                <i class="fa fa-upload"></i>
                                <span>上传签章</span>
                                <input type="file" name="fileupload" data-type="sign">
                            </span>
                            <span class="btn btn-info m-t-xs m-l-xs fileinput-button">
                                <i class="fa fa-upload"></i>
                                <span>上传同意支付</span>
                                <input type="file" name="fileupload" data-type="agree">
                            </span>
                        </div>
                        <div class="clearfix"></div>
                    </div>

                </div>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $.myGet({
            url: `/basis/teacher/self`,
            success: function (data) {
                if (data && data.code === 0) {
                    let teacher = data.teacher;
                    profileObj.formData = teacher;
                    profileObj.init();
                    for (let key in teacher) {
                        if (profileObj.myForm.find(`[name=${key}]`).length > 0) {
                            profileObj.myForm.find(`[name=${key}]`).val(teacher[key])
                        }
                    }
                    $('#profile_img_sign').attr('src', teacher.signImgPath);
                    $('#profile_img_sign').parent().attr('href', teacher.signImgPath);
                    $('#profile_img_agree').attr('src', teacher.confirmImgPath);
                    $('#profile_img_agree').parent().attr('href', teacher.confirmImgPath);
                } else {
                    toastr.error(data.msg, '操作失败')
                }
            }
        })

    })
    var profileObj = new Object({
        myForm: $('#profile_form'),
        formData: {},
        init() {
            $('input[name="fileupload"]').each(function () {
                let _type = $(this).data('type');
                let _url = _type == 'sign' ? '/basis/teacher/upload/sign/':'/basis/teacher/upload/agree/';
                $(this).fileupload({
                    dataType: 'json',
                    maxFileSize: 1*1024*1024,
                    minFileSize: 10*1024,
                    acceptFileTypes: /(\.|\/)(png|PNG)$/i,
                    messages: {
                        maxFileSize: '单个文件不能大于1MB',
                        minFileSize: '文件不能小于10KB',
                        acceptFileTypes: '只允许上传PNG图片'
                    },
                    url: _url + profileObj.formData.id,
                    done: function (e, data) {
                        if (data.result && data.result.code === 0) {
                            $('#profile_img_'+_type).attr('src', data.result.path);
                        } else {
                            toastr.error(data.result.msg, '操作失败')
                        }
                    },
                    processfail (e, data) {
                        toastr.error(data.files[0].error, '操作失败')
                    }
                });
            });
        },
        uploadSign() {

        }
    })
</script>
</body>
</html>